package com.ccb.sc.common.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

/**
 * 性别
 *
 * @author huanglongji
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@Getter
public enum Gender implements IEnum<Integer> {

    /**
     * 保密
     */
    PRIVATE(0, "保密"),

    /**
     * 男
     */
    MALE(1, "男"),

    /**
     * 女
     */
    FEMALE(2, "女");

    private int value;
    private String desc;

    Gender(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    public static Gender getByValue(Integer value) {
        for (Gender gender : Gender.values()) {
            if (value != null && gender.value == value) {
                return gender;
            }
        }
        return Gender.PRIVATE;
    }
}
